import { defineStore } from "pinia"

const useOutStockStore = defineStore('outStock', {
  state: () => ({
    goodsType: '',
    warehouseOutStatus: '',
    warehouseOutId: '',
    warehouseOutInfo: [],
    index: -1
  }),
  actions: {
    clearStore() {
      this.goodsType = ''
      this.warehouseOutStatus = ''
      this.warehouseOutId = ''
      this.warehouseOutInfo = []
      this.index = -1
    }
  },
  persist: {
    enabled: true, // 开启持久化
    strategies: [
      {
        key: 'outStock', // 存储的 key，默认为 store 的 id
        storage: sessionStorage, // 或 localStorage
        paths: ['goodsType', 'warehouseOutStatus', 'warehouseOutId', 'warehouseOutInfo', 'index'] // 需要持久化的 state 路径数组
      }
    ]
  }
})

export default useOutStockStore